package com.ojoin.trade.supplyloan_core.web.service.impl;

import com.ojoin.trade.common.exception.BusinessException;
import com.ojoin.trade.common.utils.CommonUtils;
import com.ojoin.trade.common.web.dao.BaseDao;
import com.ojoin.trade.common.web.service.impl.BaseServiceImpl;
import com.ojoin.trade.supplyloan_core.web.dao.TbSlLoanFloatDao;
import com.ojoin.trade.supplyloan_core.web.domain.TbSlLoanFloat;
import com.ojoin.trade.supplyloan_core.web.service.TbSlLoanFloatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 16-1-29
 * Time: 上午10:29
 * To change this template use File | Settings | File Templates.
 */
@Service
public class TbSlLoanFloatServiceImpl extends BaseServiceImpl<TbSlLoanFloat> implements TbSlLoanFloatService{

    @Autowired
    private TbSlLoanFloatDao dao;
    @Override
    protected BaseDao<TbSlLoanFloat> getBaseDao() {
        return dao;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public List<TbSlLoanFloat> queryFloatVoByCreditId(int idOfCredit) throws BusinessException {
        return ((TbSlLoanFloatDao)getBaseDao()).queryFloatVoByCreditId(idOfCredit);  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public String queryMemoByCreditId(int idOfCredit) throws BusinessException {
        List<TbSlLoanFloat> list= ((TbSlLoanFloatDao)getBaseDao()).queryMemoByCreditId(idOfCredit);
        StringBuilder sb=new StringBuilder();
        if(!CommonUtils.isEmpty(list)){
            for(TbSlLoanFloat vo:list){
              sb.append(vo.getMemo()).append(";");
            }
        }
        return sb.toString();
    }

    @Override
    public String queryAmountByCreditId(int idOfCredit) throws BusinessException {

        return  ((TbSlLoanFloatDao)getBaseDao()).queryAmountByCreditId(idOfCredit);
    }

    @Override
    public boolean hasFloatByJoinid(int joinid) throws BusinessException {
        List<TbSlLoanFloat> list=((TbSlLoanFloatDao)getBaseDao()).queryFloatByJoinid(joinid);
        if(CommonUtils.isEmpty(list)){
            return false;
        }
        else
            return true;
    }
}
